

# -*- coding: utf-8 -*-
import scrapy
from testScrapy.items import ImageItem
from scrapy_splash import SplashRequest

class PeopleResSpider(scrapy.Spider):
    name = 'dyGetImg'
    allowed_domains = ["quanjing.com"]
    start_urls = [
        'http://www.quanjing.com/search.aspx?q=%E9%BA%BB%E5%A9%86%E8%B1%86%E8%85%90||1|60|1|2||||#%E9%BA%BB%E5%A9%86%E8%B1%86%E8%85%90||1|100|1|2||||']
    download_delay = 2

    def start_requests(self):
        for url in self.start_urls:
            yield SplashRequest(url=url, callback=self.parse,
                                args={'wait': 1}, endpoint='render.html')

    def parse(self, response):
        item = ImageItem()
        srcs = response.xpath('//*[@id="gallery-list"]/li[*]/a/img/@src').extract()
        print(" @@@@  DATA @@@@")
        print(' DATAS len：', len(srcs))
        print(" @@@@  DATA @@@@")
        item['image_urls'] = srcs
        yield item

        # next_page = response.xpath('//*[@class="downPage"]/@href').extract_first()
        # if next_page is not None:
        #     next_page = response.urljoin(next_page)
        #     yield scrapy.Request(url= next_page, callback= self.parse)



